VERSION 5.00
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmORD500 
   BackColor       =   &H00800000&
   Caption         =   "ORD500"
   ClientHeight    =   8490
   ClientLeft      =   270
   ClientTop       =   240
   ClientWidth     =   11505
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   8490
   ScaleWidth      =   11505
   Begin MSAdodcLib.Adodc AdoEST 
      Height          =   375
      Left            =   600
      Top             =   480
      Visible         =   0   'False
      Width           =   1560
      _ExtentX        =   2752
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "EST"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.CommandButton Cmddelline 
      Caption         =   "&Del line"
      Height          =   456
      Left            =   4200
      TabIndex        =   77
      Top             =   8040
      Width           =   1128
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   456
      Left            =   9000
      TabIndex        =   76
      Top             =   8040
      Width           =   1128
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Height          =   456
      Left            =   7800
      TabIndex        =   75
      Top             =   8040
      Width           =   1128
   End
   Begin VB.CommandButton cmdReview 
      Caption         =   "&Review Order"
      Height          =   456
      Left            =   600
      TabIndex        =   73
      Top             =   8040
      Width           =   1128
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "&Edit"
      Height          =   456
      Left            =   5400
      TabIndex        =   72
      Top             =   8040
      Width           =   1128
   End
   Begin VB.TextBox txtEHAMT 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   288
      Left            =   1710
      Locked          =   -1  'True
      TabIndex        =   66
      Top             =   7680
      Width           =   1425
   End
   Begin VB.TextBox txtEHVAM 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   288
      Left            =   4860
      Locked          =   -1  'True
      TabIndex        =   65
      Top             =   7680
      Width           =   1185
   End
   Begin VB.TextBox txtEHBVA 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   288
      Left            =   10080
      Locked          =   -1  'True
      TabIndex        =   64
      Top             =   7680
      Width           =   1230
   End
   Begin VB.TextBox txtEHBCA 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   288
      Left            =   7320
      Locked          =   -1  'True
      TabIndex        =   63
      Top             =   7680
      Width           =   1395
   End
   Begin VB.Frame FrameECLine 
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   1800
      Left            =   120
      TabIndex        =   45
      Top             =   3240
      Width           =   11160
      Begin VB.TextBox txtELWGT 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   6195
         TabIndex        =   13
         Top             =   570
         Width           =   975
      End
      Begin VB.TextBox txtELPSW 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   7365
         TabIndex        =   14
         Top             =   570
         Width           =   975
      End
      Begin VB.TextBox txtELQTY 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1890
         TabIndex        =   11
         Top             =   600
         Width           =   975
      End
      Begin VB.TextBox txtELPSQ 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   3030
         TabIndex        =   12
         Top             =   600
         Width           =   975
      End
      Begin MSDataListLib.DataCombo cboELITN 
         Bindings        =   "frmORD500.frx":0000
         Height          =   390
         Left            =   6195
         TabIndex        =   62
         Top             =   105
         Visible         =   0   'False
         Width           =   4740
         _ExtentX        =   8361
         _ExtentY        =   688
         _Version        =   393216
         ListField       =   "IMITD"
         BoundColumn     =   "IMITN"
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "VNI-Helve"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.ComboBox cboELSTT 
         ForeColor       =   &H000000FF&
         Height          =   315
         ItemData        =   "frmORD500.frx":0015
         Left            =   10050
         List            =   "frmORD500.frx":002E
         TabIndex        =   51
         Top             =   1470
         Width           =   1125
      End
      Begin VB.TextBox txtELAMT 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   6195
         Locked          =   -1  'True
         TabIndex        =   50
         Top             =   1470
         Width           =   1380
      End
      Begin VB.TextBox txtELBCA 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1890
         Locked          =   -1  'True
         TabIndex        =   49
         Top             =   1470
         Width           =   1395
      End
      Begin VB.ComboBox cboELPER 
         Height          =   315
         ItemData        =   "frmORD500.frx":0081
         Left            =   6195
         List            =   "frmORD500.frx":008E
         TabIndex        =   17
         Top             =   1035
         Width           =   1230
      End
      Begin VB.TextBox txtELPRC 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1890
         TabIndex        =   16
         Top             =   1035
         Width           =   975
      End
      Begin VB.TextBox txtELITN 
         Alignment       =   1  'Right Justify
         BeginProperty Font 
            Name            =   "VNI-Helve"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   6195
         TabIndex        =   10
         Top             =   105
         Width           =   1425
      End
      Begin VB.TextBox txtELITD 
         BeginProperty Font 
            Name            =   "VNI-Helve"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   7665
         Locked          =   -1  'True
         TabIndex        =   18
         Top             =   105
         Width           =   3270
      End
      Begin VB.TextBox txtELOLN 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1890
         Locked          =   -1  'True
         TabIndex        =   48
         Top             =   75
         Width           =   525
      End
      Begin VB.TextBox txtELPDC 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   9495
         TabIndex        =   15
         Top             =   600
         Width           =   825
      End
      Begin VB.TextBox txtELBVA 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   3360
         Locked          =   -1  'True
         TabIndex        =   47
         Top             =   1470
         Width           =   1125
      End
      Begin VB.TextBox txtELVAM 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   7920
         Locked          =   -1  'True
         TabIndex        =   46
         Top             =   1470
         Width           =   1125
      End
      Begin VB.Line Line6 
         BorderColor     =   &H80000002&
         BorderWidth     =   2
         X1              =   0
         X2              =   11160
         Y1              =   1440
         Y2              =   1440
      End
      Begin VB.Line Line5 
         X1              =   7320
         X2              =   7200
         Y1              =   600
         Y2              =   810
      End
      Begin VB.Line Line4 
         X1              =   3000
         X2              =   2880
         Y1              =   600
         Y2              =   825
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Line status"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   240
         Index           =   23
         Left            =   9120
         TabIndex        =   61
         Top             =   1515
         Width           =   975
      End
      Begin VB.Label lbl 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "Base currency/VAT"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   22
         Left            =   45
         TabIndex        =   60
         Top             =   1515
         Width           =   1845
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Line amount/VAT"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   21
         Left            =   4560
         TabIndex        =   59
         Top             =   1515
         Width           =   1620
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Price Per*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   20
         Left            =   5145
         TabIndex        =   58
         Top             =   1095
         Width           =   975
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Unit price*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   19
         Left            =   735
         TabIndex        =   57
         Top             =   1080
         Width           =   1110
      End
      Begin VB.Label lbl 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "Weight Cust. Order / Packed slip*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   405
         Index           =   18
         Left            =   4410
         TabIndex        =   56
         Top             =   510
         Width           =   1665
      End
      Begin VB.Label lbl 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "Quantity Cust. Order / Packed slip*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   390
         Index           =   17
         Left            =   60
         TabIndex        =   55
         Top             =   540
         Width           =   1785
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Item No*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   16
         Left            =   5085
         TabIndex        =   54
         Top             =   105
         Width           =   990
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Invoice lines"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   15
         Left            =   720
         TabIndex        =   53
         Top             =   135
         Width           =   1140
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Discount %*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   180
         Index           =   24
         Left            =   8370
         TabIndex        =   52
         Top             =   615
         Width           =   1095
      End
      Begin VB.Line Line2 
         X1              =   3360
         X2              =   3240
         Y1              =   1500
         Y2              =   1725
      End
      Begin VB.Line Line3 
         X1              =   7800
         X2              =   7680
         Y1              =   1500
         Y2              =   1710
      End
   End
   Begin MSAdodcLib.Adodc AdoSMM 
      Height          =   375
      Left            =   3840
      Top             =   0
      Visible         =   0   'False
      Width           =   1740
      _ExtentX        =   3069
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "7 SMM"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc AdoECH 
      Height          =   330
      Left            =   1680
      Top             =   600
      Visible         =   0   'False
      Width           =   1830
      _ExtentX        =   3228
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "6 ECH"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Frame FrameBB 
      BackColor       =   &H00800000&
      BorderStyle     =   0  'None
      Caption         =   "Frame2"
      Height          =   2760
      Left            =   0
      TabIndex        =   24
      Top             =   735
      Width           =   11400
      Begin MSDataListLib.DataCombo cboEHSTN 
         Bindings        =   "frmORD500.frx":00AF
         DataField       =   "STSTN"
         Height          =   315
         Left            =   1680
         TabIndex        =   83
         Top             =   1320
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   556
         _Version        =   393216
         ListField       =   "STSTN"
         BoundColumn     =   "STSTN"
         Text            =   ""
      End
      Begin VB.TextBox txtEHVAT 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   10035
         TabIndex        =   81
         Top             =   1320
         Width           =   690
      End
      Begin VB.TextBox txtEHPTC 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   10035
         TabIndex        =   8
         Top             =   1770
         Width           =   1170
      End
      Begin MSDataListLib.DataCombo cboEHCCD 
         Bindings        =   "frmORD500.frx":00C4
         Height          =   315
         Left            =   6435
         TabIndex        =   44
         Top             =   2115
         Width           =   1170
         _ExtentX        =   2064
         _ExtentY        =   556
         _Version        =   393216
         ListField       =   "CMCCD"
         BoundColumn     =   "CMCCD"
         Text            =   ""
      End
      Begin MSDataListLib.DataCombo cboEHSNO 
         Bindings        =   "frmORD500.frx":00D9
         Height          =   360
         Left            =   6420
         TabIndex        =   0
         Top             =   900
         Visible         =   0   'False
         Width           =   3210
         _ExtentX        =   5662
         _ExtentY        =   635
         _Version        =   393216
         ListField       =   "MMNME"
         BoundColumn     =   "MMSNO"
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "VNI-Helve"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.TextBox txtMMNME 
         BeginProperty Font 
            Name            =   "VNI-Helve"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   7335
         TabIndex        =   43
         Top             =   900
         Width           =   2160
      End
      Begin VB.TextBox txtEHCPO 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   6435
         TabIndex        =   7
         Top             =   1740
         Width           =   1170
      End
      Begin VB.TextBox txtEHNOL 
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1665
         TabIndex        =   42
         Top             =   2160
         Width           =   480
      End
      Begin VB.TextBox txtEHSNO 
         BeginProperty Font 
            Name            =   "VNI-Helve"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   6420
         TabIndex        =   4
         Top             =   900
         Width           =   885
      End
      Begin VB.TextBox txtEHDUE 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1680
         TabIndex        =   6
         Top             =   1770
         Width           =   1215
      End
      Begin VB.TextBox txtEHSTA 
         BeginProperty Font 
            Name            =   "VNI-Helve"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   6435
         TabIndex        =   5
         Top             =   1335
         Width           =   3105
      End
      Begin MSDataListLib.DataCombo cboEHCNO 
         Bindings        =   "frmORD500.frx":00EE
         DataField       =   "CMCNO"
         DataSource      =   "AdoRCM"
         Height          =   360
         Left            =   1680
         TabIndex        =   35
         Top             =   900
         Visible         =   0   'False
         Width           =   3435
         _ExtentX        =   6059
         _ExtentY        =   635
         _Version        =   393216
         ListField       =   "CMNME"
         BoundColumn     =   "CMCNO"
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "VNI-Helve"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.TextBox txtEHODN 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1680
         TabIndex        =   2
         Top             =   480
         Width           =   975
      End
      Begin VB.TextBox txtEHDTE 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   6435
         TabIndex        =   3
         Top             =   500
         Width           =   1170
      End
      Begin VB.TextBox txtEHCNO 
         BeginProperty Font 
            Name            =   "VNI-Helve"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1680
         TabIndex        =   19
         Top             =   900
         Width           =   750
      End
      Begin VB.TextBox txtEHCER 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   10035
         TabIndex        =   9
         Top             =   2115
         Width           =   1170
      End
      Begin VB.TextBox txtCMNME 
         BeginProperty Font 
            Name            =   "VNI-Helve"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   2490
         TabIndex        =   27
         Top             =   900
         Width           =   2595
      End
      Begin VB.ComboBox cboEHSTT 
         ForeColor       =   &H000000FF&
         Height          =   315
         ItemData        =   "frmORD500.frx":0103
         Left            =   9930
         List            =   "frmORD500.frx":011C
         TabIndex        =   26
         Top             =   60
         Width           =   1350
      End
      Begin VB.ComboBox cboEHITP 
         Height          =   315
         ItemData        =   "frmORD500.frx":016F
         Left            =   4920
         List            =   "frmORD500.frx":0179
         TabIndex        =   25
         Top             =   30
         Width           =   1365
      End
      Begin Crystal.CrystalReport CrystalReport2 
         Left            =   0
         Top             =   0
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin VB.Label Label1 
         BackColor       =   &H00800000&
         Caption         =   "Vat %"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Left            =   10080
         TabIndex        =   82
         Top             =   960
         Width           =   975
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "VAT %*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   26
         Left            =   0
         TabIndex        =   80
         Top             =   0
         Width           =   735
      End
      Begin VB.Label lblEHDTE 
         AutoSize        =   -1  'True
         BackColor       =   &H00800000&
         Caption         =   "(dd/mm/yyyy)"
         ForeColor       =   &H0000FFFF&
         Height          =   195
         Index           =   1
         Left            =   3000
         TabIndex        =   79
         Top             =   1800
         Width           =   960
      End
      Begin VB.Label lblEHDTE 
         AutoSize        =   -1  'True
         BackColor       =   &H00800000&
         Caption         =   "(dd/mm/yyyy)"
         ForeColor       =   &H0000FFFF&
         Height          =   195
         Index           =   0
         Left            =   6480
         TabIndex        =   78
         Top             =   240
         Width           =   960
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Term code"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   28
         Left            =   8610
         TabIndex        =   71
         Top             =   1800
         Width           =   1320
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Number Of line"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   180
         Index           =   29
         Left            =   20
         TabIndex        =   41
         Top             =   2175
         Width           =   1275
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Customer PO No"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   27
         Left            =   4860
         TabIndex        =   40
         Top             =   1830
         Width           =   1470
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Payment due date"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   180
         Index           =   25
         Left            =   20
         TabIndex        =   39
         Top             =   1785
         Width           =   1575
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Saleman No*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   10
         Left            =   5220
         TabIndex        =   38
         Top             =   960
         Width           =   1110
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Ship to Address"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   8
         Left            =   4920
         TabIndex        =   37
         Top             =   1320
         Width           =   1425
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Ship to No"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   180
         Index           =   6
         Left            =   20
         TabIndex        =   36
         Top             =   1395
         Width           =   855
      End
      Begin VB.Line Line1 
         X1              =   2160
         X2              =   5340
         Y1              =   5280
         Y2              =   4455
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Order No*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   180
         Index           =   2
         Left            =   20
         TabIndex        =   34
         Top             =   570
         Width           =   870
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Customer Order Date*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   3
         Left            =   4350
         TabIndex        =   33
         Top             =   540
         Width           =   2040
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Order Type"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0080FFFF&
         Height          =   255
         Index           =   4
         Left            =   3480
         TabIndex        =   32
         Top             =   120
         Width           =   1305
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Customer No*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   180
         Index           =   5
         Left            =   20
         TabIndex        =   31
         Top             =   975
         Width           =   1200
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Currency Code*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   7
         Left            =   4890
         TabIndex        =   30
         Top             =   2190
         Width           =   1440
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Exchange Rate*"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   9
         Left            =   8490
         TabIndex        =   29
         Top             =   2145
         Width           =   1440
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Invoice status"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   255
         Index           =   13
         Left            =   8430
         TabIndex        =   28
         Top             =   120
         Width           =   1380
      End
   End
   Begin MSAdodcLib.Adodc AdoCCM 
      Height          =   375
      Left            =   7440
      Top             =   240
      Visible         =   0   'False
      Width           =   1785
      _ExtentX        =   3149
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "5 CUR_EX"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc AdoECL 
      Height          =   360
      Left            =   2040
      Top             =   0
      Visible         =   0   'False
      Width           =   1755
      _ExtentX        =   3096
      _ExtentY        =   635
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "4 INVOICE"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc AdoIIM 
      Height          =   345
      Left            =   3600
      Top             =   840
      Visible         =   0   'False
      Width           =   1725
      _ExtentX        =   3043
      _ExtentY        =   609
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "3 IIM"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc AdoAVM 
      Height          =   330
      Left            =   7440
      Top             =   0
      Visible         =   0   'False
      Width           =   1800
      _ExtentX        =   3175
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "2. AVM"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc AdoRCM 
      Height          =   330
      Left            =   5760
      Top             =   0
      Visible         =   0   'False
      Width           =   1695
      _ExtentX        =   2990
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "1 RCM"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.CommandButton cmdNewItem 
      Caption         =   "New &line"
      Height          =   456
      Left            =   3000
      TabIndex        =   23
      Top             =   8040
      Width           =   1128
   End
   Begin VB.CommandButton cmdAddNew 
      Caption         =   "New &Order"
      Height          =   456
      Left            =   1800
      TabIndex        =   22
      Top             =   8040
      Width           =   1128
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "&Save"
      Height          =   456
      Left            =   6600
      TabIndex        =   21
      Top             =   8040
      Width           =   1128
   End
   Begin MSDataGridLib.DataGrid grdECL 
      Bindings        =   "frmORD500.frx":019C
      Height          =   2220
      Left            =   150
      TabIndex        =   67
      Top             =   5400
      Width           =   11175
      _ExtentX        =   19711
      _ExtentY        =   3916
      _Version        =   393216
      BackColor       =   -2147483624
      ForeColor       =   8388608
      HeadLines       =   1
      RowHeight       =   19
      FormatLocked    =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "VNI-Times"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   11
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   "ELOLN"
         Caption         =   "Line"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column02 
         DataField       =   "ELITN"
         Caption         =   "Item"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column03 
         DataField       =   "ELITD"
         Caption         =   "Item Description"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column04 
         DataField       =   "ELQTY"
         Caption         =   "Quantity"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column05 
         DataField       =   "ELWGT"
         Caption         =   "Weight"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column06 
         DataField       =   "ELPRC"
         Caption         =   "Unit price"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column07 
         DataField       =   "ELPER"
         Caption         =   "Price per"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column08 
         DataField       =   "ELAMT"
         Caption         =   "Line amount"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column09 
         DataField       =   "ELBCA"
         Caption         =   "Base Cur Amount"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column10 
         DataField       =   "ELSTT"
         Caption         =   "Status"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
            ColumnWidth     =   14.74
         EndProperty
         BeginProperty Column01 
            ColumnWidth     =   329.953
         EndProperty
         BeginProperty Column02 
            ColumnWidth     =   1184.882
         EndProperty
         BeginProperty Column03 
            ColumnWidth     =   2670.236
         EndProperty
         BeginProperty Column04 
            ColumnWidth     =   705.26
         EndProperty
         BeginProperty Column05 
            ColumnWidth     =   1005.165
         EndProperty
         BeginProperty Column06 
            ColumnWidth     =   945.071
         EndProperty
         BeginProperty Column07 
            ColumnWidth     =   705.26
         EndProperty
         BeginProperty Column08 
            ColumnWidth     =   1305.071
         EndProperty
         BeginProperty Column09 
            ColumnWidth     =   1305.071
         EndProperty
         BeginProperty Column10 
            ColumnWidth     =   645.165
         EndProperty
      EndProperty
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "VAT amount"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   240
      Index           =   11
      Left            =   8880
      TabIndex        =   85
      Top             =   7725
      Width           =   1080
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Amount"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   240
      Index           =   12
      Left            =   6480
      TabIndex        =   84
      Top             =   7725
      Width           =   735
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Customer Order Entry"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   16.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   540
      Index           =   32
      Left            =   1800
      TabIndex        =   74
      Top             =   720
      Width           =   4470
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Invoice lines"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   14
      Left            =   30
      TabIndex        =   70
      Top             =   5130
      Width           =   1200
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   " Base VAT amount"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   30
      Left            =   3240
      TabIndex        =   69
      Top             =   7710
      Width           =   1560
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Base Amount"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   31
      Left            =   480
      TabIndex        =   68
      Top             =   7725
      Width           =   1170
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Customer Order Entry"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   16.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   540
      Index           =   1
      Left            =   2535
      TabIndex        =   20
      Top             =   240
      Width           =   4470
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "ORD500"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   450
      Index           =   0
      Left            =   75
      TabIndex        =   1
      Top             =   -45
      Width           =   1830
   End
End
Attribute VB_Name = "frmORD500"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim INVType(3), StaOrd(7), Per(3), OldEHODN As String, OldELOLN As String, NewTrans As Byte, OldCurRate As Double
Dim oldstt As Integer
Dim oldEHDTE, oldEHCNO, oldCMNME, oldEHSNO, oldMMNME, oldEHSTN As String
Dim oldEHSTA, oldEHDUE, oldEHCPO, oldEHPTC, oldEHVAT, oldEHCER, oldEHNOL, oldEHAMT, oldEHVAM, oldEHBAM, oldEHBVA As String
Dim WithEvents RecOrd As ADODB.Recordset
Attribute RecOrd.VB_VarHelpID = -1
Dim SQL As String
Sub RefeshLineAmount()
    On Error Resume Next
    Dim Amount
    If txtELITN = "" Then Exit Sub
    
    If Not ((Val(txtELQTY) > 0 Or Val(txtELWGT) > 0) And Val(txtELPRC) > 0 & _
        Left(cboELPER.Text, 1) <> "") Then
        Exit Sub
    End If
    
    Select Case cboELPER.ListIndex + 1
    Case 1
        
        Amount = Val(txtELQTY) * (Val(txtELPRC) - (Val(txtELPRC) * Val(txtELPDC) / 100))
        txtELBCA = Round(Val(Amount) * Val(txtEHCER), 2)
        
        txtELBVA = Round(Val(txtELBCA) * (Val(txtEHVAT) / 100), 2)
                
        txtELAMT = Round(Val(txtELQTY) * (Val(txtELPRC) & _
        -(Val(txtELPRC) * Val(txtELPDC) / 100)), 2)
        
        txtELVAM = Round(Val(txtELAMT) * (Val(txtEHVAT) / 100), 2)
        
    Case 2
        
        Amount = Val(txtELWGT) * (Val(txtELPRC) - (Val(txtELPRC) * Val(txtELPDC) / 100))
        txtELBCA = Round(Val(Amount) * Val(txtEHCER), 2)
        
        txtELBVA = Round(Val(txtELBCA) * (Val(txtEHVAT) / 100), 2)
        
        Amount = Val(txtELWGT) * (Val(txtELPRC) & _
        -(Val(txtELPRC) * Val(txtELPDC) / 100))
        
        txtELAMT = Round(Amount, 2)
        txtELVAM = Round(Val(txtELAMT) * (Val(txtEHVAT) / 100), 2)
End Select
    txtELBCA = Format(txtELBCA, "##,##0.00")
    txtELBVA = Format(txtELBVA, "##,##0.00")
    txtELAMT = Format(txtELAMT, "##,##0.00")
    txtELVAM = Format(txtELVAM, "##,##0.00")
End Sub
Sub SaveOldValue()
    OldEHODN = txtEHODN
    'cboEHITP.ListIndex
    'cboEHSTT.ListIndex
    oldEHDTE = txtEHDTE
    oldEHCNO = txtEHCNO
    oldCMNME = txtCMNME
    oldEHSNO = txtEHSNO
    oldMMNME = txtMMNME
    oldEHSTN = cboEHSTN
    oldEHSTA = txtEHSTA
    oldEHDUE = txtEHDUE
    oldEHCPO = txtEHCPO
    oldEHPTC = txtEHPTC
    oldEHVAT = txtEHVAT
    'cboEHCCD = cboEHCCD
    oldEHCER = txtEHCER
    oldEHNOL = txtEHNOL
    oldEHAMT = txtEHAMT
    oldEHVAM = txtEHVAM
    oldEHBAM = txtEHBAM
    oldEHBVA = txtEHBVA
    '----------------------
    OldELOLN = txtELOLN
   oldELITN = txtELITN
   oldELITD = txtELITD
   oldELQTY = txtELQTY
   oldELWGT = txtELWGT
   oldELPSQ = txtELPSQ
   oldELPSW = txtELPSW
   oldELPRC = txtELPRC
   'cboELPER = ""
   oldELPDC = txtELPDC
   oldELAMT = txtELAMT
   oldELVAM = txtELVAM
   oldELBCA = txtELBCA
   oldELBVA = txtELBVA
   oldEHVAT = txtEHVAT
    
End Sub
Sub RetoreOldValue()
    'cboELSTT.ListIndex = 0
   txtEHODN = OldEHODN
    'cboEHITP.ListIndex
    'cboEHSTT.ListIndex
    txtEHDTE = oldEHDTE
    txtEHCNO = oldEHCNO
    txtCMNME = oldCMNME
    txtEHSNO = oldEHSNO
    txtMMNME = oldMMNME
    cboEHSTN = oldEHSTN
    txtEHSTA = oldEHSTA
    txtEHDUE = oldEHDUE
    txtEHCPO = oldEHCPO
    txtEHPTC = oldEHPTC
    txtEHVAT = oldEHVAT
    'cboEHCCD = cboEHCCD
    txtEHCER = oldEHCER
    txtEHNOL = oldEHNOL
    txtEHAMT = oldEHAMT
    txtEHVAM = oldEHVAM
    txtEHBAM = oldEHBAM
    txtEHBVA = oldEHBVA
    '----------------------
    txtELOLN = OldELOLN
   txtELITN = oldELITN
   txtELITD = oldELITD
   txtELQTY = oldELQTY
   txtELWGT = oldELWGT
   txtELPSQ = oldELPSQ
   txtELPSW = oldELPSW
   txtELPRC = oldELPRC
   'cboELPER = ""
   txtELPDC = oldELPDC
   txtELAMT = oldELAMT
   txtELVAM = oldELVAM
   txtELBCA = oldELBCA
   txtELBVA = oldELBVA
   txtEHVAT = oldEHVAT
End Sub



Private Sub cboEHSTN_Click(Area As Integer)
On Error GoTo Err_cboEHSTN_Click
If Area = 1 Then
    Exit Sub
End If
AdoEST.ConnectionString = ConnectString
AdoEST.ConnectionTimeout = 10
AdoEST.CommandType = adCmdText
AdoEST.RecordSource = "Select STSTN,STCNM from EST Where STCNO='" & txtEHCNO & "'"
AdoEST.Refresh
If Area = 2 Then
      
    Result = Find("EST", "STSAD", "WHERE STCNO='" & txtEHCNO & _
    "' AND STSTN='" & cboEHSTN.BoundText & "'")
    If Result = "" Then
        MsgBox " Khong co so dia chi cho so ship to nay"
        cboEHSTN.SetFocus
    Else
        txtEHSTA = Result
        txtEHDUE.SetFocus
    End If
   
End If

Next_cboEHSTN_Click:
    Exit Sub
Err_cboEHSTN_Click:
    MsgBox Err.Description
    Resume Next_cboEHSTN_Click

End Sub

Private Sub cboEHSTN_KeyPress(KeyAscii As Integer)
On Error GoTo Err_cboEHSTN_KeyPress
If KeyAscii = 13 Then
      
    Result = Find("EST", "STSAD", "WHERE STCNO='" & txtEHCNO & _
    "' AND STSTN='" & cboEHSTN.BoundText & "'")
    If Result = "" Then
        MsgBox " Khong co so dia chi cho so ship to nay"
        cboEHSTN.SetFocus
    Else
        txtEHSTA = Result
        txtEHDUE.SetFocus
    End If
   
End If

Next_cboEHSTN_KeyPress:
    Exit Sub
Err_cboEHSTN_KeyPress:
    MsgBox Err.Description
    Resume Next_cboEHSTN_KeyPress
End Sub


Private Sub Form_Activate()
'txtEHCNO.SetFocus
End Sub

Private Sub Form_Load()
On Error GoTo Form_Load_err:
NewTrans = False
ISEDITING = False
ISADDING = False
OpenFile
ButtonStatus
cmdNewItem.Enabled = False ' moi them vao
Cmddelline.Enabled = False ' moi them vao
cmdEdit.Enabled = False

Form_Load_next:
    Exit Sub
Form_Load_err:
    MsgBox "Form_Load Error : " & Err.Description
    Resume Form_Load_next:
End Sub
Sub ScreenNewOrder()
    On Error Resume Next
    Dim OrdNo As String
    OrdNo = GetOrdNo()
    If OrdNo = "" Then
        MsgBox "Khong Tao Duoc Ma So"
        Exit Sub
    End If
    txtEHODN = OrdNo
    cboEHITP.ListIndex = 0
    cboEHSTT.ListIndex = 0
    txtEHDTE = Format(WorkingDate, "dd/mm/yyyy")
    txtEHCNO = ""
    txtCMNME = ""
    txtEHSNO = ""
    txtMMNME = ""
    cboEHSTN = ""
    txtEHSTA = ""
    txtEHDUE = ""
    txtEHCPO = ""
    txtEHPTC = ""
    txtEHVAT = 5
    cboEHCCD = ""
    txtEHCER = 0
    txtEHNOL = 0
    txtEHAMT = 0
    txtEHVAM = 0
    txtEHBAM = 0
    txtEHBVA = 0
    Call SaveOldValue
End Sub
Sub ScreenNewNewLine()
On Error Resume Next
   cboELSTT.ListIndex = 0
   txtELOLN = GetOrdLine()
   txtELITN = ""
   txtELITD = ""
   txtELQTY = ""
   txtELWGT = ""
   txtELPSQ = 0
   txtELPSW = 0
   txtELPRC = ""
   cboELPER = ""
   txtELPDC = 0
   txtELAMT = 0 ' Line amount
   txtELVAM = 0 ' VAT line (VND)
   txtELBCA = 0 ' Base currency line amount
   txtELBVA = 0 ' VAT base currency
  
  Call SaveOldValue
End Sub
Sub ScreenReview()
On Error GoTo WriteToScreen_err
    Call ScreenReviewECH
   
    Call ScreenReviewECL
WriteToScreen_next:
    Exit Sub
WriteToScreen_err:
    MsgBox Err.Description & " Write toscreen Function"
    Resume WriteToScreen_next:
End Sub
Sub ScreenReviewECH()
    On Error GoTo Check_Err:
    Dim recECH As Recordset
    Set recECH = DBconn.Execute("select ECH.* from ECH where ECH.EHODN='" & txtEHODN & "'")
    If recECH.EOF Then
        Exit Sub
    End If
    With recECH
        ' Set gia tri cho kieu order
        For i = 0 To cboEHITP.ListCount - 1
            If Left(cboEHITP.List(i), 1) = !EHITP Then
                cboEHITP.ListIndex = i
                Exit For
            End If
        Next i
        'Set gia tri cho trang thai order
        For i = 0 To cboEHSTT.ListCount - 1
            If Left(cboEHSTT.List(i), 1) = !EHSTT Then
                cboEHSTT.ListIndex = i
                Exit For
            End If
        Next i
        txtEHODN = !EHODN
        OldEHODN = txtEHODN
        txtEHDTE = IIf(IsNull(!EHDTE), "", Format(!EHDTE, "dd/mm/yyyy"))
        txtEHCNO = !EHCNO
        txtCMNME = Find("RCM", "CMNME", " WHERE CMCNO='" & txtEHCNO & "'")
        txtEHSNO = !EHSNO
        txtMMNME = Find("SMM", "MMNME", " WHERE MMSNO='" & txtEHSNO & "'")
        txtEHVAT = !EHVAT * 100
        cboEHSTN = !EHSTN
        txtEHSTA = !EHSTA
        txtEHCPO = IIf(IsNull(!EHCPO), 0, !EHCPO)
        txtEHPTC = IIf(IsNull(!EHPTC), "", !EHPTC)
        txtEHDUE = Format(!EHDUE, "dd/mm/yyyy")
        cboEHCCD.BoundText = !EHCCD
        txtEHCER = !EHCER
        OldCurRate = txtEHCER
        txtEHNOL = IIf(IsNull(!EHNOL), 0, !EHNOL)
        txtEHAMT = !EHAMT
        txtEHVAM = !EHVAM
        txtEHBCA = !EHBAM
        txtEHBVA = !EHBVA
        .Close
    End With
    
    Call SaveOldValue
check_err_next:
    Exit Sub
Check_Err:
    MsgBox " ScreenReviewECH: " & Err.Description:
    Resume check_err_next:
End Sub
Sub ScreenReviewECL()
    On Error GoTo Err_ScreenReviewECL
    If AdoECL.Recordset.EOF Then
        MsgBox "No Item Review or Line No invalid"
        Exit Sub
    End If
    
    If AdoECL.Recordset.EOF Then
        Exit Sub
    End If
    With AdoECL.Recordset
        For i = 0 To cboELSTT.ListCount - 1
            If Left(cboELSTT.List(i), 1) = !ELSTT Then
                cboELSTT.ListIndex = i
                Exit For
            End If
        Next i
        txtELOLN = !ELOLN
        OldELODN = !ELOLN
        txtELITN = !ELITN
        txtELITD = !ELITD
        txtELQTY = !ELQTY
        txtELPSQ = IIf(IsNull(!ELPSQ), 0, !ELPSQ)
        txtELWGT = !ELWGT
        txtELPSW = IIf(IsNull(!ELPSW), 0, !ELPSW)
        txtELPRC = !ELPRC
        For i = 0 To cboELPER.ListCount - 1
            If Left(cboELPER.List(i), 1) = !ELPER Then
                cboELPER.ListIndex = i
                Exit For
            End If
        Next i
        txtELPDC = IIf(IsNull(!ELPDC), 0, !ELPDC)
        txtELAMT = !ELAMT ' Line amount
        txtELVAM = !ELVAM ' VAT line (VND)
        txtELBCA = !ELBCA ' Base currency line amount
        txtELBVA = !ELBVA ' VAT base currency
        '.Close
    End With
     
     Call SaveOldValue
Next_ScreenReviewECL:
    Exit Sub
Err_ScreenReviewECL:
    MsgBox Err.Description
    Resume Next_ScreenReviewECL
End Sub


Sub WriteToScreen()
On Error GoTo WriteToScreen_err
    Dim recECL As Recordset
    
    If NewTrans Then
        
        Call ScreenNewOrder
    End If
    If ISADDING Then
        'AdoCCM.Refresh
        'AdoECL.Refresh
       Call ScreenNewNewLine
    End If
    If ISEDITING Then 'Sua chua du lieu
        'AdoCCM.Refresh
        'AdoECL.Refresh
        Call ScreenReview
    End If
    
    
WriteToScreen_next:
    Exit Sub
WriteToScreen_err:
    MsgBox Err.Description & " Write toscreen Function"
    Resume WriteToScreen_next:
End Sub

Function GetOrdLine()
On Error GoTo GetOrdLine_err
    Set rstECL = New ADODB.Recordset
    SQL = "SELECT max(ELOLN)AS LineMax FROM ECL WHERE ELODN= '" & Trim(txtEHODN.Text) & "'"
    rstECL.Open SQL, ConnectString, adOpenKeyset, adLockOptimistic
    If rstECL.RecordCount <> 0 And (rstECL.EOF) Then
        GetOrdLine = rstECL!LineMax + 1
    Else
        If IsNull(rstECL!LineMax) Then
            GetOrdLine = 1
        Else
            GetOrdLine = rstECL!LineMax + 1
        End If
    End If
    rstECL.Close
GetOrdLine_next:
    Exit Function
GetOrdLine_err:
    MsgBox "GetOrdLine Error : " & Err.Description
    Resume GetOrdLine_next:
End Function


Function GetOrdNo()
'Lay so tiep theo
On Error GoTo GetOrdNo_err:
    
    Dim SQL
    Dim sdate
    Dim PrefixOrd, OrdNext
    sdate = Format(Year(Now) & "/" & Month(Now()) & "/01", "yyyy/mm/dd hh:mm:ss")
    If Now() = sdate Then
        GetOrdNo = "I" & Format(Now(), "yy") & Format(Now(), "mm") & "01"
        Exit Function
    End If
       
    SQL = "SELECT MAX(Substring(EHODN,6,Len(EHODN))+1) as CurOrdNo FROM ECH" _
        & " WHERE EHDTE >= '" & sdate & "'"
    Dim RecCountLine As Recordset
    Set RecCountLine = DBconn.Execute(SQL)
    If RecCountLine.EOF Then
        Exit Function
    End If
    If IsNull(RecCountLine!CurOrdNO) Then
        GetOrdNo = "I" & Format(Now(), "yy") & Format(Now(), "mm") & "001"
        Exit Function
    End If
    
    OrdNext = Val(RecCountLine!CurOrdNO)
    RecCountLine.Close
    
    PrefixOrd = "I" & Format(Now(), "yy") & Format(Now(), "mm")
    
    If OrdNext >= 1 And OrdNext <= 9 Then
        GetOrdNo = PrefixOrd & "00" & (OrdNext)
    ElseIf OrdNext > 9 And OrdNext <= 99 Then
        GetOrdNo = PrefixOrd & "0" & (OrdNext)
    Else
        GetOrdNo = PrefixOrd & (OrdNext)
    End If

GetOrdNo_next:
    Exit Function
GetOrdNo_err:
    MsgBox "GetOrdNo Error : " & Err.Description
    Resume GetOrdNo_next:

End Function

'Function GetOrdNo() 'Lay truc tiep tu database
'    On Error GoTo GetOrdNo_err:
'
'    Dim SQL As String
'    SQL = "select dbo.fn_ORDRetrieveOrdNo('ORD')as OrdNo"
'    Dim rstOrdNo As Recordset
'    Set rstOrdNo = DBconn.Execute(SQL)
'    If rstOrdNo.EOF Then
'        GetOrdNo = 0
'        MsgBox "Khong Tao Duoc Order Number"
'        Exit Function
'    Else
'        GetOrdNo = rstOrdNo!OrdNo
'        DBconn.Execute ("Update ZSN Set Sothutu=Sothutu+1 Where maloai='ORD'")
'        Set rstOrdNo = DBconn.Execute("select sothutu from ZSN where Maloai='ORD'")
'        oldstt = rstOrdNo!sothutu
'        rstOrdNo.Close
'    End If
'
'GetOrdNo_next:
'    Exit Function
'GetOrdNo_err:
'    MsgBox "GetOrdNo Error : " & Err.Description
'    Resume GetOrdNo_next:
'
'End Function
Sub UpdateNOLine()
On Error GoTo UpdateNOLine_err
    Dim SQLstr
    Dim RecCountLine As Recordset
    Set RecCountLine = DBconn.Execute("SELECT ELODN, COUNT(ELOLN) AS CountLine From ECL " & _
    " WHERE (ELODN = '" & txtEHODN & "') AND (ELSTT <> N'7')GROUP BY ELODN")
    txtEHNOL = RecCountLine!CountLine
    RecCountLine.Close
    SQLstr = "Update ECH set EHNOL='" & txtEHNOL & "' WHERE EHODN='" & txtEHODN & "'"
    DBconn.Execute (SQLstr)
UpdateNOLine_next:
    Exit Sub
UpdateNOLine_err:
    MsgBox "UpdateNOLine Sub: " & Err.Description
    Resume UpdateNOLine_next:

End Sub
Sub WritetoECH(InputType As String)
    On Error GoTo WritetoECH_err
    Dim Objcmd As Command
    Set Objcmd = New ADODB.Command
    Objcmd.CommandType = adCmdStoredProc
    Set Objcmd.ActiveConnection = DBconn
    Objcmd.CommandText = "sp_Ord_Write_ECH"
        'Objcmd.Parameters.Refresh
        Objcmd(1) = InputType
        Objcmd(2) = txtEHODN.Text
        Objcmd(3) = Format(txtEHDTE, "dd/mm/yyyy")
        Objcmd(4) = cboEHITP.ListIndex + 1
        Objcmd(5) = txtEHCNO
        Objcmd(6) = cboEHSTN
        Objcmd(7) = txtEHPTC
        Objcmd(8) = txtEHSTA
        Objcmd(9) = txtEHSNO
        Objcmd(10) = txtEHCPO
        Objcmd(11) = cboEHCCD.BoundText
        Objcmd(12) = txtEHCER
        Objcmd(13) = txtEHNOL
        Objcmd(14) = IIf(txtEHVAT = "", 0.05, txtEHVAT / 100)
        Objcmd(15) = Format(Now(), "yyyy-mm-dd hh:mm:ss")
        Objcmd(16) = IIf(txtEHDUE = "", Null, Format(txtEHDUE, "dd/mm/yyyy"))
        Objcmd(17) = "E"
          
        ' Execute once and display...
        Objcmd.Execute
WritetoECH_next:
    Exit Sub
WritetoECH_err:
    MsgBox Err.Description
    Resume WritetoECH_next:
End Sub
Sub WritetoECL(InputType As String)
    On Error GoTo WritetoECL_err
    Dim Objcmd As Command
    Set Objcmd = New ADODB.Command
    Objcmd.CommandType = adCmdStoredProc
    Set Objcmd.ActiveConnection = DBconn
    Objcmd.CommandText = "sp_Ord_Write_ECL"
        'Objcmd.Parameters.Refresh
        Objcmd(1) = InputType
        Objcmd(2) = txtEHODN
        Objcmd(3) = Val(txtELOLN)
        Objcmd(4) = txtELITN
        Objcmd(5) = txtELITD
        Objcmd(6) = ""
        Objcmd(7) = ""
        Objcmd(8) = txtELQTY
        Objcmd(9) = txtELWGT
        Objcmd(10) = txtELPRC
        Objcmd(11) = cboELPER.ListIndex + 1
        Objcmd(12) = txtELPDC
        Objcmd(13) = Val(txtEHVAT) / 100
        Objcmd(14) = txtELAMT
        Objcmd(15) = txtELVAM
        Objcmd(16) = txtELBCA
        Objcmd(17) = txtELBVA
        Objcmd(18) = txtELPSQ
        Objcmd(19) = txtELPSW
        Objcmd(20) = Format(Now(), "yyyy-mm-dd hh:mm:ss")
        Objcmd(21) = "N"
        Objcmd(22) = UserLogin
        Objcmd(23) = cboELSTT.ListIndex + 1
          
        ' Execute once and display...
        Objcmd.Execute
WritetoECL_next:
    Exit Sub
WritetoECL_err:
    MsgBox Err.Description
    Resume WritetoECL_next:
        
End Sub

Function Check()
On Error GoTo Check_Err:
    Check = True
    If NewTrans Then ' nhap moi them vao ECH
        Set rst = New ADODB.Recordset
        SQL = "SELECT EHODN FROM ECH WHERE EHODN= '" & Trim(txtEHODN.Text) & "'"
        rst.Open SQL, ConnectString, adOpenKeyset, adLockOptimistic
        If rst.RecordCount <> 0 Then
            MsgBox "The Order " & Trim(txtEHODN.Text) & " is Already exist"
            Check = False
            txtEHODN.SetFocus
            Exit Function
        End If
    'Kiem tra status khi sua chua du lieu
    ElseIf ISEDITING Then
        SQL = "SELECT EHSTT,ELSTT FROM ECH JOIN ECL ON ECH.EHODN=ECL.ELODN WHERE EHODN= '" & Trim(txtEHODN.Text) & "'" & _
        " AND ECL.ELOLN='" & txtELOLN & "'"
         Set recECH_ECL = DBconn.Execute(SQL)
        'rst.Open SQL, ConnectString, adOpenKeyset, adLockOptimistic
        If recECH_ECL.RecordCount <> 0 Then
            
            If recECH_ECL!EHSTT = 6 Then ' kiem tra toan bo Order
                MsgResult = MsgBox("This Order has finished.You can't change data", vbOKOnly, "Warning")
                Check = False
                Exit Function
            End If
            If recECH_ECL!ELSTT = 6 Then
                    MsgResult = MsgBox("This item has finished.You can't change data", vbOKOnly, "Warning")
                    Check = False
                    Exit Function
              
            End If
        End If
    End If
    
    If txtEHODN = "" Then
         MsgBox "You must enter the Order Number", vbOKOnly, "Error entry"
         Check = False
         txtEHODN.SetFocus
         Exit Function
    End If
     ' Kiem tra ma khach hang
    If txtEHCNO.Text = "" Then
           MsgBox "You must enter Customer No", vbOKOnly, "Error entry"
           Check = False
           txtEHCNO.SetFocus
           Exit Function
    End If
    'kiem tra ngay Order
    If (txtEHDTE.Text = "") Or (Not IsDate(txtEHDTE.Text)) Then
        MsgBox "You must enter Order Date", vbOKOnly, "Error entry"
        Check = False
        txtEHDTE.SetFocus
        Exit Function
    End If
     'kiem tra Currency code
    If (cboEHCCD.BoundText = "") Then
        MsgBox "You must fill Currency code", vbOKOnly, "Error entry"
        cboEHCCD.SetFocus
        Check = False
        Exit Function
    End If
      'kiem tra Exchange rate
    If (txtEHCER.Text = "") Or Not IsNumeric(txtEHCER.Text) Then
        MsgBox "You must fill exchange rate", vbOKOnly, "Error entry"
        Check = False
        txtEHCER.SetFocus
        Exit Function
    End If
    If (txtELQTY = "") Or (txtELPSQ = "") Or (txtELWGT = "") Or (txtELPSW = "") Then
        MsgBox "You must enter values in Quantity and Weight textbox", vbOKOnly, "Error entry"
        Check = False
        txtELQTY.SetFocus
        Exit Function
    End If
    If Not (IsNumeric(txtELQTY) And IsNumeric(txtELPSQ) And IsNumeric(txtELWGT) And IsNumeric(txtELPSW)) Then
        MsgBox "You must enter number values in Quantity and Weight textbox", vbOKOnly, "Error entry"
        Check = False
        txtELQTY.SetFocus
        Exit Function
    End If
     'kiem tra unit price
    If (txtELPRC.Text = "") Or Not IsNumeric(txtELPRC.Text) Then
        MsgBox "You must fill unit price textbox", vbOKOnly, "Error entry"
        Check = False
        txtELPRC.SetFocus
        Exit Function
    End If
    'kiem tra tinh theo kl hay so luong
    If (cboELPER.Text = "") Then
        MsgBox "You must fill price per textbox", vbOKOnly, "Error entry"
        Check = False
        cboELPER.SetFocus
        Exit Function
    End If
    'kiem tra VAT
    If (txtEHVAT.Text = "") Then
        MsgBox "You must enter VAT textbox", vbOKOnly, "Error entry"
        Check = False
        txtEHVAT.SetFocus
        Exit Function
    End If
Check_next:
    Exit Function
Check_Err:
    MsgBox "Check function: " & Err.Description
    Resume Check_next:
End Function
Private Sub cboEHCCD_Click(Area As Integer) '01
On Error GoTo Err_cboEHCCD_Click
If Area = 1 Then
    Exit Sub
End If
AdoCCM.ConnectionString = ConnectString
AdoCCM.ConnectionTimeout = 10
AdoCCM.CommandType = adCmdText
AdoCCM.RecordSource = "Select * from CCM"
AdoCCM.Refresh
If Area = 2 Then
      
    Result = Find("CCI", "CICCR", "WHERE CICCD='" & cboEHCCD.BoundText & "'")
    If Result = "" Then
        MsgBox " Can not find Exchange rate for currency code"
        cboEHCCD.SetFocus
    Else
        txtEHCER = Result
        txtEHCER.SetFocus
    End If
   
End If

Next_cboEHCCD_Click:
    Exit Sub
Err_cboEHCCD_Click:
    MsgBox Err.Description
    Resume Next_cboEHCCD_Click
End Sub

Private Sub cboEHCCD_KeyPress(KeyAscii As Integer)
On Error GoTo Err_action
    If KeyAscii = 13 Then
        Result = Find("CCI", "CICCR", "WHERE CICCD='" & cboEHCCD.BoundText & "'")
        If Result = "" Then
            MsgBox " Can not find Exchange rate for currency code"
            cboEHCCD.SetFocus
        Else
            txtEHCER = Result
            txtEHCER.SetFocus
        End If
    End If
    
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action
End Sub


Private Sub cboEHCNO_Click(Area As Integer)
If Area = 1 Then
    Exit Sub
End If


On Error GoTo Err_action
'AdoRCM.Refresh
If Area = 2 Then
    txtEHCNO = cboEHCNO.BoundText
    txtCMNME = cboEHCNO.Text
    cboEHCNO.Visible = False
    txtEHSNO.SetFocus
End If
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action
End Sub

Private Sub cboEHCNO_LostFocus()
    On Error GoTo Err_action
'AdoRCM.Refresh
    If cboEHCNO.BoundText = "" Then
        MsgBox "Ban phai chon mot ma khach hang"
        'cboEHCNO.SetFocus
        Exit Sub
    End If
      
    txtEHCNO = cboEHCNO.BoundText
    txtCMNME = cboEHCNO.Text
    cboEHCNO.Visible = False
   
    
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action
End Sub


Private Sub cboEHITP_Click()
'    txtEHODN.SetFocus
End Sub

Private Sub cboEHSNO_Click(Area As Integer)
On Error GoTo Err_action
'AdoSMM.Refresh
If Area = 2 Then
    txtEHSNO = cboEHSNO.BoundText
    txtMMNME = cboEHSNO.Text
    cboEHSNO.Visible = False
    cboEHSTN.SetFocus
End If
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub cboEHSTT_Click()

'MsgBox Left(cboEHSTT.List(cboEHSTT.ListIndex), 1)
End Sub

Private Sub cboELITN_Click(Area As Integer)
On Error GoTo Err_action
'AdoIIM.Refresh
    If Area = 2 Then
        txtELITN = cboELITN.BoundText
        txtELITD = Find("IIM", "IMETD", " WHERE IMITN='" & txtELITN & "'")
        txtELPRC = Find("IIM", "IMPRC", "WHERE IMITN='" & txtELITN & "'")
        cboELITN.Visible = False
        cmdSave.Enabled = True
        txtELQTY.SetFocus
           
    End If
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub
Private Sub cboELITN_KeyPress(KeyAscii As Integer)
 On Error GoTo Err_action

    If KeyAscii <> 13 Then
        MsgBox "Phai chon mot item"
        cboELITN.SetFocus
        Exit Sub
    End If
    txtELITN = cboELITN.BoundText
    txtELITD = Find("IIM", "IMETD", " WHERE IMITN='" & txtELITN & "'")
    txtELPRC = Find("IIM", "IMPRC", "WHERE IMITN='" & txtELITN & "'")
    cboELITN.Visible = False
    cmdSave.Enabled = True
    txtELQTY.SetFocus
    
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action
End Sub

Private Sub cboELITN_LostFocus()
On Error GoTo Err_action
    txtELITN = cboELITN.BoundText
    If txtELITN = "" Then
        MsgBox "Phai chon mot item"
        'cboELITN.SetFocus
        Exit Sub
    End If
    txtELPRC = Find("IIM", "IMPRC", "WHERE IMITN='" & txtELITN & "'")
    txtELITD = Find("IIM", "IMITD", " WHERE IMITN='" & txtELITN & "'")
    cboELITN.Visible = False
    cmdSave.Enabled = True
    'txtELVAT = VATRate(txtEHCNO, txtELITN)
    'txtELQTY.SetFocus
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action
End Sub

Private Sub cboELPER_Click()

Dim DiscAMT, DiscBAM
On Error GoTo Err_action
Call RefeshLineAmount
'Select Case cboELPER.ListIndex + 1
'    Case 1
'
'        txtELBCA = Val(txtELQTY) * (Val(txtELPRC) - (Val(txtELPRC) * Val(txtELPDC) / 100))
'        txtELBVA = Val(txtELBCA) * Val(txtEHVAT)
'
'        txtELAMT = Val(txtELQTY) * (Val(txtELPRC) - (Val(txtELPRC) * Val(txtELPDC) / 100)) * Val(txtEHCER)
'        txtELVAM = Val(txtELAMT) * Val(txtEHVAT)
'
'    Case 2
'
'        txtELBCA = Val(txtELWGT) * (Val(txtELPRC) - (Val(txtELPRC) * Val(txtELPDC) / 100))
'        txtELBVA = Val(txtELBCA) * Val(txtEHVAT)
'
'        txtELAMT = Val(txtELWGT) * (Val(txtELPRC) - (Val(txtELPRC) * Val(IIf(txtELPDC = "", 0, txtELPDC)) / 100)) * Val(txtEHCER)
'        txtELVAM = Val(txtELAMT) * Val(txtEHVAT)
'End Select

Next_Action:
  Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

'txtELVAT.SetFocus
End Sub

Private Sub cboELPER_KeyPress(KeyAscii As Integer)
On Error GoTo Err_action
    If KeyAscii <> 13 Then
        Exit Sub
    End If
    Select Case Left(cboELPER.Text, 1)
        Case "1"
            cboELPER.ListIndex = 0
            cmdSave.SetFocus
        Case "2"
            cboELPER.ListIndex = 1
            cmdSave.SetFocus
        Case Else
            MsgBox "Nhap lai cach tinh gia : 1-tinh theo soluong; 2-tinh theo khoi luong"
            cboELPER.SetFocus
    End Select
    
Next_Action:
      Exit Sub
Err_action:
        MsgBox Err.Description
        Resume Next_Action
    
End Sub
Private Sub cboELPER_LostFocus()
On Error GoTo Err_action
    Select Case Left(cboELPER.Text, 1)
        Case "1"
            cboELPER.ListIndex = 0
        Case "2"
            cboELPER.ListIndex = 1
        Case Else
            MsgBox "Nhap lai cach tinh gia : 1-tinh theo soluong; 2-tinh theo khoi luong"
    End Select
Next_Action:
      Exit Sub
Err_action:
        MsgBox Err.Description
        Resume Next_Action
End Sub
Private Sub cmdReview_Click()
On Error GoTo Err_action
'Chuyen ten form dung .tag
frmReview.Tag = "ORD500"
frmReview.Show 1
NewTrans = False
ISEDITING = True
ISADDING = False
If frmReview.Tag = "" Then
    Exit Sub
End If
    txtEHODN = frmReview.Tag
    Unload frmReview
    'txtELOLN = 1
    AdoECL.RecordSource = "Select ECL.* from ECL " & _
    " LEFT JOIN ECH ON ECL.ELODN=ECH.EHODN where ECH.EHODN ='" & txtEHODN & "' ORDER BY ELOLN"
    AdoECL.Refresh
    WriteToScreen
    cmdEdit.Enabled = True
    cmdAddNew.Enabled = True
    cmdNewItem.Enabled = True
    Cmddelline.Enabled = True
    FrameBB.Enabled = False
    FrameECLine.Enabled = False
Call SaveOldValue
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action
End Sub


Private Sub cmdAddnew_Click()

On Error GoTo addnew_err:
'OpenFile
    NewTrans = True
    ISADDING = True
    ISEDITING = False
    WriteToScreen
    'ButtonStatus
    FrameBB.Enabled = True
    FrameECLine.Enabled = True
    cmdReview.Enabled = False
    cmdAddNew.Enabled = False
    cmdNewItem.Enabled = False
    cmdEdit.Enabled = False
    Cmddelline.Enabled = False
    cmdSave.Enabled = False
    cmdCancel.Enabled = True
    txtEHCNO.SetFocus
    'AdoCCM.Refresh
    AdoRCM.Refresh
    AdoSMM.Refresh
    'AdoEST.Refresh
addnew_next:
    Exit Sub
addnew_err:
    MsgBox Err.Description
    Resume addnew_next
End Sub
Private Sub cmdNewItem_Click()
On Error GoTo Err_action
'NewTrans = True
'OpenFile
If txtEHODN = "" Then
    Exit Sub
End If
   
    NewTrans = False
    ISADDING = True
    ISEDITING = False
    WriteToScreen
    'ButtonStatus
    FrameBB.Enabled = True
    FrameECLine.Enabled = True
    cmdReview.Enabled = False
    cmdAddNew.Enabled = False
    cmdNewItem.Enabled = False
    cmdEdit.Enabled = False
    Cmddelline.Enabled = False
    cmdSave.Enabled = True
    cmdCancel.Enabled = True
    txtELITN.SetFocus

Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub
Private Sub cmdEdit_Click()
'OpenFile
On Error GoTo Err_action
NewTrans = False
ISADDING = False
ISEDITING = True
'WriteToScreen
'ButtonStatus
    cmdReview.Enabled = False
    cmdAddNew.Enabled = False
    cmdNewItem.Enabled = False
    cmdEdit.Enabled = False
    Cmddelline.Enabled = False
    cmdSave.Enabled = True
    cmdCancel.Enabled = True
    FrameBB.Enabled = True
    FrameECLine.Enabled = True
Call SaveOldValue
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub cmdCancel_Click()
On Error GoTo Err_action
If NewTrans Then
    Dim rsttemp As Recordset
    txtEHODN = ""
'    Set rsttemp = DBconn.Execute("select sothutu from ZSN where Maloai='ORD'")
'    If rsttemp!sothutu = oldstt Then
'        DBconn.Execute ("Update ZSN Set Sothutu=Sothutu-2")
'    End If
End If
'NewTrans = False
'ISADDING = False
'ISEDITING = False
Call RetoreOldValue
'ButtonStatus
FrameBB.Enabled = False
FrameECLine.Enabled = False
If NewTrans Then
    cmdReview.Enabled = True
    cmdAddNew.Enabled = True
    cmdNewItem.Enabled = False
    cmdEdit.Enabled = False
    Cmddelline.Enabled = False
    cmdSave.Enabled = False
    cmdCancel.Enabled = False
    Exit Sub
End If
If ISEDITING Then
    cmdReview.Enabled = True
    cmdAddNew.Enabled = True
    cmdNewItem.Enabled = True
    cmdEdit.Enabled = True
    Cmddelline.Enabled = True
    cmdSave.Enabled = False
    cmdCancel.Enabled = False
    Exit Sub
End If
If ISADDING Then
    cmdReview.Enabled = True
    cmdAddNew.Enabled = True
    cmdNewItem.Enabled = True
    cmdEdit.Enabled = True
    Cmddelline.Enabled = True
    cmdSave.Enabled = False
    cmdCancel.Enabled = False
    Exit Sub
End If
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub cmddelline_Click()
On Error GoTo Err_action
cmdReview.Enabled = True
cmdAddNew.Enabled = True
cmdNewItem.Enabled = True
cmdEdit.Enabled = True
Cmddelline.Enabled = True
cmdSave.Enabled = False
cmdCancel.Enabled = False

Dim Result As String
Result = Find("ECH", "EHODN", "WHERE EHODN='" & txtEHODN & "'" & " AND EHSTT='1'")
If Result = "" Then
    MsgBox " Order nay da bi khoa"
    Exit Sub
End If

If txtEHODN.Text <> "" And txtELOLN.Text <> "" Then
    ' SQL = "delete from ECL where ELOLN='" & Trim(txtELOLN.Text) & "'" & " AND ELSTT = '1'" & " AND ELOLN='" & Trim(txtELOLN.Text) & "'"

     If MsgBox(" Do you want delete this line ?", vbDefaultButton2 + vbOKCancel + vbCritical, "Deleting...") = vbOK Then
          'DBconn.Execute (SQL)
          
        With AdoECL.Recordset
            .Delete
            .MoveNext
            If .EOF Then .MoveLast
        End With
            ScreenReviewECL
        Exit Sub
          
          'AdoECL.Refresh
     Else
          Exit Sub
     End If

Else
    MsgBox "The TextBox OrderNo or ItemNo is Empty...!", vbCritical, "Warning"
End If

Next_Action:
    Exit Sub
Err_action:
    MsgBox "Can not delete this line !", vbCritical, "Warning"
    Resume Next_Action

End Sub






Private Sub cmdSave_Click()

    On Error GoTo Err_action
    If Check = False Then
        MsgBox "Loi nhap lieu"
        Exit Sub
    End If

''
''    If Not ValidInput() Then Exit Sub
    
    WriteToFile
    AdoECL.RecordSource = "Select ECL.* from ECL " & _
        " LEFT JOIN ECH ON ECL.ELODN=ECH.EHODN where ECH.EHODN ='" & txtEHODN & "' ORDER BY ELOLN"
    AdoECL.Refresh
    FrameBB.Enabled = False
    FrameECLine.Enabled = False
If NewTrans Then
    cmdReview.Enabled = True
    cmdAddNew.Enabled = True
    cmdNewItem.Enabled = True
    cmdEdit.Enabled = True
    Cmddelline.Enabled = False
    cmdSave.Enabled = False
    cmdCancel.Enabled = False
    Exit Sub
End If
If ISEDITING Then
    cmdReview.Enabled = True
    cmdAddNew.Enabled = True
    cmdNewItem.Enabled = True
    cmdEdit.Enabled = True
    Cmddelline.Enabled = True
    cmdSave.Enabled = False
    cmdCancel.Enabled = False
    Exit Sub
End If
If ISADDING Then
    cmdReview.Enabled = True
    cmdAddNew.Enabled = True
    cmdNewItem.Enabled = True
    cmdEdit.Enabled = True
    Cmddelline.Enabled = True
    cmdSave.Enabled = False
    cmdCancel.Enabled = False
    Exit Sub
End If
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub


Private Sub cmdExit_Click()

Unload frmORD500
End Sub

Private Sub grdECL_Click()

On Error GoTo Err_grdECLClick
txtELOLN = grdECL.Columns(1).value
NewTrans = False
ISADDING = False
ISEDITING = True

WriteToScreen
If SELECTROW = "" Then SELECTROW = 1
AdoECL.Recordset.AbsolutePosition = SELECTROW
Next_grdECLClick:
    Exit Sub
Err_grdECLClick:
    MsgBox Err.Description
    Resume Next_grdECLClick:
End Sub

Private Sub grdECL_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error GoTo GrdECL_RowColChange_err:
    SELECTROW = AdoECL.Recordset.Bookmark
GrdECL_RowColChange_next:
    Exit Sub
GrdECL_RowColChange_err:
    MsgBox "GrdECL_RowColChange Error : " & Err.Description
    Resume GrdECL_RowColChange_next:

End Sub








Private Sub txtEHCER_KeyPress(KeyAscii As Integer)
    On Error Resume Next
    If KeyAscii <> 13 Then
        Exit Sub
    End If
    If Val(txtEHCER) < 1 Then
        MsgBox "Gia tri ngoai te khong hop le"
        txtEHCER.SetFocus
        Exit Sub
    End If
    
    txtELITN.SetFocus
    Call RefeshLineAmount
End Sub

Private Sub txtEHCER_LostFocus()
    If Val(txtEHCER) < 1 Then
        MsgBox "Gia tri ngoai te khong hop le"
        'txtEHCER.SetFocus
        Exit Sub
    End If
       
    Call RefeshLineAmount
End Sub

Private Sub txtEHCNO_KeyPress(KeyAscii As Integer)
On Error GoTo Err_action
    Dim Result As String
    If KeyAscii <> 13 Then
        Exit Sub
    End If
    Result = Find("RCM", "CMNME", "WHERE CMCNO='" & txtEHCNO & "'")
    If Result = "" Then
        MsgBox "Khong co ma khach hang nay"
        AdoRCM.Refresh
        cboEHCNO.Visible = True
        cboEHCNO.SetFocus
        Exit Sub
    Else
        cboEHCNO.Visible = False
        txtCMNME = Result
        Dim rstCusInfo As Recordset
        Set rstCusInfo = DBconn.Execute("Select CMSTN,CMSNO,CMVAT,CMPTC from RCM where CMCNO='" & _
        txtEHCNO & "'")
        txtEHVAT = 100 * Find("VVR", "VRVPC", "WHERE VRITV='" & rstCusInfo!CMVAT & _
        "'" & " AND VRCVT='" & rstCusInfo!CMVAT & "'")
        txtEHSNO = rstCusInfo!CMSNO
        txtMMNME = Find("SMM", "MMNME", "WHERE MMSNO='" & rstCusInfo!CMSNO & "'")
        txtEHPTC = rstCusInfo!CMPTC
        cboEHSTN = rstCusInfo!CMSTN
        txtEHSTA = Find("EST", "STSAD", "WHERE STCNO='" & txtEHCNO & _
        "'" & " AND STSTN='" & rstCusInfo!CMSTN & "'")
        txtEHDUE.SetFocus
        
    End If


Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub txtEHCNO_LostFocus()
On Error GoTo Err_action
    Dim Result As String
    Result = Find("RCM", "CMNME", "WHERE CMCNO='" & txtEHCNO & "'")
    If Result = "" Then
        MsgBox "Khong co ma khach hang nay"
        cboEHCNO.Visible = True
        'cboEHCNO.SetFocus
    Else
         cboEHCNO.Visible = False
        txtCMNME = Result
        Dim rstCusInfo As Recordset
        Set rstCusInfo = DBconn.Execute("Select CMSTN,CMSNO,CMVAT,CMPTC from RCM where CMCNO='" & _
        txtEHCNO & "'")
        txtEHVAT = 100 * Find("VVR", "VRVPC", "WHERE VRITV='" & rstCusInfo!CMVAT & _
        "'" & " AND VRCVT='" & rstCusInfo!CMVAT & "'")
        txtEHSNO = rstCusInfo!CMSNO
        txtMMNME = Find("SMM", "MMNME", "WHERE MMSNO='" & rstCusInfo!CMSNO & "'")
        txtEHPTC = rstCusInfo!CMPTC
        cboEHSTN = rstCusInfo!CMSTN
        txtEHSTA = Find("EST", "STSAD", "WHERE STCNO='" & txtEHCNO & _
        "'" & " AND STSTN='" & rstCusInfo!CMSTN & "'")
        txtEHDUE.SetFocus
    End If

Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub txtEHCPO_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtEHPTC.SetFocus
End Sub

Private Sub txtEHDTE_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtEHCNO.SetFocus
End Sub

Private Sub txtEHDUE_KeyPress(KeyAscii As Integer)
On Error GoTo Err_action
If KeyAscii = 13 Then
    txtEHCPO.SetFocus
    If Not IsDate(txtEHDUE) Then
        MsgBox "Date entry invalid"
        txtEHDUE.SetFocus
    End If
End If

Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub txtEHDUE_LostFocus()
On Error GoTo Err_action
    If txtEHDUE <> "" Then
        If Not IsDate(txtEHDUE) Then
            MsgBox "Date entry invalid"
            'txtEHDUE.SetFocus
        End If
    End If

Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub



Private Sub txtEHODN_KeyPress(KeyAscii As Integer)
On Error GoTo Err_action
If KeyAscii = 13 Then
    Result = Find("ECH", "EHODN", "WHERE EHODN='" & txtEHODN & "'")
    If Result = "" Then
       txtEHDTE.SetFocus
    Else
        MsgBox "Order Number is already exist"
        txtEHODN = Result
        NewTrans = False
        ISADDING = False
        ISEDITING = False
        WriteToScreen
        ButtonStatus
    End If
End If

Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub txtEHPTC_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        cboEHCCD.SetFocus
    End If
End Sub

Private Sub txtEHSNO_KeyPress(KeyAscii As Integer)
On Error GoTo Err_action
If KeyAscii = 13 Then
    Dim Result As String
    Result = Find("SMM", "MMNME", "WHERE MMSNO='" & txtEHSNO & "'")
    If Result = "" Then
        MsgBox "Khong co ma nguoi ban"
        AdoSMM.Refresh
        cboEHSNO.Visible = True
        cboEHSNO.SetFocus
    Else
        cboEHSNO.Visible = False
        txtMMNME = Result
        cboEHSTN.SetFocus
    End If
End If

Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub txtEHSNO_LostFocus()
    Dim Result As String
    Result = Find("SMM", "MMNME", "WHERE MMSNO='" & txtEHSNO & "'")
    If Result = "" Then
        'MsgBox "Khong co ma nguoi ban nay"
        cboEHSNO.Visible = True
        'cboEHSNO.SetFocus
    Else
        cboEHSNO.Visible = False
        txtMMNME = Result
    End If
End Sub

Private Sub txtEHSTA_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtEHDUE.SetFocus
End Sub



Private Sub txtEHVAT_KeyPress(KeyAscii As Integer)
    
    If KeyAscii <> 13 Then
        Exit Sub
    End If
    If Not IsNumeric(txtEHVAT) Then
        MsgBox "Gia tri nhap phai la so"
        txtEHVAT.SetFocus
        Exit Sub
    End If
    If Val(txtEHVAT) < 0 Then
        MsgBox "Gia tri nhap phai lon hon hay bang 0"
        txtEHVAT.SetFocus
        Exit Sub
    End If
    If (Val(txtEHVAT) / 100) > 1 Then
        MsgBox "Gia tri nhap phai nho hon 100"
        txtEHVAT.SetFocus
        Exit Sub
    End If
    txtEHDUE.SetFocus
   

End Sub

Private Sub txtEHVAT_LostFocus()

        If Not IsNumeric(txtEHVAT) Then
            MsgBox "Gia tri nhap phai la so"
            Exit Sub
        End If
        If Val(txtEHVAT) < 0 Then
            MsgBox "Gia tri nhap phai lon hon hay bang 0"
            'txtEHVAT.SetFocus
            Exit Sub
        End If
        If (Val(txtEHVAT) / 100) > 1 Then
            MsgBox "Gia tri nhap phai nho hon 100"
            'txtEHVAT.SetFocus
            Exit Sub
        End If
        'txtEHDUE.SetFocus
End Sub

Private Sub txtELAMT_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtELVAM.SetFocus
End Sub

Private Sub txtELBCA_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtELBVA.SetFocus
End Sub

Private Sub txtELBVA_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtELAMT.SetFocus
End Sub


Private Sub txtELITN_KeyPress(KeyAscii As Integer)
On Error GoTo result_err:
If KeyAscii = 13 Then
    Dim Result As String
    Result = Find("IIM", "IMITD", "WHERE IMITN='" & txtELITN & "'")
    If Result = "" Then
        AdoIIM.Refresh
        cboELITN.Visible = True
        cboELITN.SetFocus
        Exit Sub
    Else
        txtELITD = Result
        txtELPRC = Find("IIM", "IMPRC", "WHERE IMITN='" & txtELITN & "'")
        cboELITN.Visible = False
        txtELQTY.SetFocus
        cmdSave.Enabled = True
    End If
    'set lai khoi luong tuong ung
    If (Val(txtELPSQ) <> 0) Or (Val(txtELQTY) <> 0) Then
        txtELWGT.SetFocus
        Dim RecIIM As Recordset
        Set RecIIM = DBconn.Execute("Select IMWPU from IIM where IMITN='" & txtELITN & "'")
        If RecIIM.EOF Then
            txtELWGT = 0
            txtELWGT.SelLength = 1
            txtELWGT.SelStart = 0
            txtELWGT.SelText = 1
            txtELWGT.SetFocus
            Exit Sub
        End If
        If IsNull(RecIIM!IMWPU) Then
            txtELWGT = 0
            txtELWGT.SetFocus
        Else
            txtELPSW = RecIIM!IMWPU * txtELPSW
            txtELWGT = RecIIM!IMWPU * txtELQTY
            txtELPSQ.SetFocus
        End If
        
            
    End If
End If
result_next:
    Exit Sub
result_err:
    MsgBox Err.Description
    Resume result_next
End Sub
Sub OpenFile()
On Error GoTo Err_Openfile
AdoRCM.ConnectionString = ConnectString
AdoRCM.ConnectionTimeout = 10
AdoRCM.CommandType = adCmdText
AdoRCM.RecordSource = "Select CMCNO,CMNME from RCM" & _
" ORDER BY CMNME"
'AdoRCM.Refresh

AdoAVM.ConnectionString = ConnectString
AdoAVM.ConnectionTimeout = 10
AdoAVM.CommandType = adCmdText
AdoAVM.RecordSource = "Select * from AVM"
'AdoAVM.Refresh

FieldDel = "IMRID"
DelStatus = "IZ"
SQL = "Select IMITN,IMITN +'  '+IMITD as IMITD  from IIM where " & FieldDel & " <>'" & DelStatus & "' "
AdoIIM.ConnectionString = ConnectString
AdoIIM.ConnectionTimeout = 10
AdoIIM.CommandType = adCmdText
AdoIIM.RecordSource = SQL
'AdoIIM.Refresh

AdoECL.ConnectionString = ConnectString
AdoECL.ConnectionTimeout = 10
AdoECL.CommandType = adCmdText
AdoECL.RecordSource = "Select ECL.* from ECL " & _
    " LEFT JOIN ECH ON ECL.ELODN=ECH.EHODN where ECH.EHODN ='" & txtEHODN & "' ORDER BY ELOLN"
'AdoECL.Refresh

'AdoCCM.Refresh

'Adodc6.ConnectionString = ConnectString
'Adodc6.ConnectionTimeout = 10
'Adodc6.CommandType = adCmdText
'Adodc6.RecordSource = "Select * from ECH"
'Adodc6.Refresh

AdoSMM.ConnectionString = ConnectString
AdoSMM.ConnectionTimeout = 10
AdoSMM.CommandType = adCmdText
AdoSMM.RecordSource = "Select * from SMM"
'AdoSMM.Refresh
AdoRCM.ConnectionString = ConnectString
AdoRCM.ConnectionTimeout = 10
AdoRCM.CommandType = adCmdText
AdoRCM.RecordSource = "Select CMCNO,CMNME from RCM"


' Create array from combobox Custtype,StatusOrder, ValuePer
INVType(1) = "1 Normal"
INVType(2) = "2 By pass Inventory"

StaOrd(1) = "1 New"
StaOrd(2) = "2 Printed"
StaOrd(3) = "3 Confirmed"
StaOrd(4) = "4 B/O"
StaOrd(5) = "5 Caredit hold"
StaOrd(6) = ""
StaOrd(7) = "7 Canceled"
Per(1) = "Unt"
Per(2) = "Wgt"
Next_Openfile:
    Exit Sub
Err_Openfile:
    MsgBox Err.Description
    Resume Next_Openfile
End Sub

Sub ButtonStatus()
On Error GoTo Err_action
    cmdAddNew.Enabled = Not ISEDITING
    cmdReview.Enabled = Not ISEDITING
    cmdNewItem.Enabled = Not ISEDITING
    cmdEdit.Enabled = Not ISEDITING
    Cmddelline.Enabled = Not ISEDITING
    cmdSave.Enabled = ISEDITING Or ISADDING
    cmdCancel.Enabled = ISEDITING Or ISADDING
    

    FrameBB.Enabled = ISEDITING Or ISADDING 'NewTrans
    FrameECLine.Enabled = ISEDITING Or ISADDING
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Sub WriteToFile()
    On Error GoTo ord500_err:
    Dim msg, strSQL
    'Kiem tra trang thai cua Order
  
    Result = Find("ECH", "EHSTT", "WHERE EHODN='" & txtEHODN & "'")
    If Result <> "1" And Result <> "7" And Result <> "" Then
        MsgBox "Order nay da bi khoa khong the thay doi duoc"
        NewTrans = False
        ISADDING = False
        ISEDITING = False
        ButtonStatus
        Exit Sub
    End If
    
    If NewTrans Then
        WritetoECH ("add")
    End If
    'them mot mat hang moi vao trong Order
    If ISADDING Then
        WritetoECL ("add")
        'WriteToIIM txtELITN, Val(txtELWGT), Val(txtELQTY)
    ElseIf ISEDITING Then 'Cap nhat du lieu
        If txtEHODN <> OldEHODN Then
            msg = MsgBox(" Are you sure change the Order Number?", vbOKCancel, "Warning")
            If msg = vbCancel Then
                Exit Sub
            Else
                strSQL = "Update ECH set EHODN='" & txtEHODN & "'" & " WHERE EHODN='" & OldEHODN & "'"
                'MsgBox strSQL
                DBconn.Execute (strSQL)
            End If
        End If
        WritetoECH ("upd")
        WritetoECL ("upd")
    End If
    Call UpdateNOLine
    'recECL.Close
    Set recECL = DBconn.Execute("SELECT ELODN, SUM(ELVAM) AS SumELVAM, SUM(ELAMT)" & _
        " AS SumELAMT, SUM(ELBVA) AS SumELBVA, SUM(ELBCA) " & _
        " AS SumELBCA FROM ECL WHERE (ELODN = '" & txtEHODN & "') GROUP BY ELODN")
    With recECL
        txtEHAMT = Round(!SumELAMT, 2)
        txtEHVAM = Round(!SumELVAM, 2)
        txtEHBCA = Round(!SumELBCA, 2)
        txtEHBVA = Round(!SumELBVA, 2)
    End With
        
    recECL.Close
    
        DBconn.Execute ("UPDATE ECH SET EHAMT=" & txtEHAMT & ",EHVAM=" & txtEHVAM & ",EHBAM=" & txtEHBCA & ",EHBVA=" & txtEHBVA & " WHERE EHODN='" & txtEHODN & "'")
        txtEHAMT = Format(txtELAMT, "##,##0.00")
        txtEHVAM = Format(txtELVAM, "##,##0.00")
        txtEHBCA = Format(txtELBCA, "##,##0.00")
        txtEHBVA = Format(txtELBVA, "##,##0.00")
ord500_next:
    Exit Sub
ord500_err:
    MsgBox "Write to file Sub: " & Err.Description
    Resume ord500_next
End Sub

Sub WriteToIIM(ITN, WGT, unit)

unit = IIf(IsNumeric(unit), unit, 0)
 WGT = IIf(IsNumeric(WGT), WGT, 0)
    

SQL = "UPDATE IIM SET IMCOW=IMCOW+" & WGT & ",IMCOU=IMCOU+" & unit & " WHERE IMITN='" & ITN & "'"
DBconn.Execute SQL

End Sub


Private Sub txtELITN_LostFocus()
On Error GoTo Err_action
Dim Result As String
    Result = Find("IIM", "IMITD", "WHERE IMITN='" & txtELITN & "'")
    If Result = "" Then
        MsgBox "Don't have this Item code"
        cboELITN.Visible = True
        'cboELITN.SetFocus
    Else
    
        txtELITD = Result
        txtELPRC = Find("IIM", "IMPRC", "WHERE IMITN='" & txtELITN & "'")
        cboELITN.Visible = False
        'txtELVAT = VATRate(txtEHCNO, txtELITN)
       
    End If
    'Tinh lai khoi luong tuong ung
    If (Val(txtELPSQ) <> 0) Or (Val(txtELQTY) <> 0) Then
        'txtELWGT.SetFocus
        Dim RecIIM As Recordset
        Set RecIIM = DBconn.Execute("Select IMWPU from IIM where IMITN='" & txtELITN & "'")
        If Not RecIIM.EOF Then
            If IsNull(RecIIM!IMWPU) Then
                txtELWGT = 0
                txtELPSW = 0
                'txtELWGT.SetFocus
            Else
                txtELPSW = RecIIM!IMWPU * txtELPSW
                txtELWGT = RecIIM!IMWPU * txtELQTY
                
            End If
        Else
            txtELWGT = 0
        End If
    End If
    
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub txtELPDC_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtELPRC.SetFocus
End Sub

Private Sub txtELPRC_KeyPress(KeyAscii As Integer)
    If KeyAscii <> 13 Then
        Exit Sub
    End If
    If Val(txtELPRC) < 0 Then
        MsgBox "Gia nhap khong hop le"
        txtELPRC.SetFocus
        Exit Sub
    Else
        cboELPER.SetFocus
        Call RefeshLineAmount
    End If
    


End Sub



Private Sub txtELPRC_LostFocus()
    If Val(txtELPRC) < 0 Then
        MsgBox "Gia nhap khong hop le"
        'txtELPRC.SetFocus
        Exit Sub
    End
        Call RefeshLineAmount
    End If
End Sub

'Private Sub txtELPSQ_KeyPress(KeyAscii As Integer)
'    If KeyAscii = 13 Then
'        Dim RecIIM As Recordset
'        Set RecIIM = DBconn.Execute("Select IMWPU from IIM where IMITN='" & txtELITN & "'")
'        If Not RecIIM.EOF Then
'            If IsNull(RecIIM!IMWPU) Then
'                txtELPSW = ""
'            Else
'                txtELPSW = RecIIM!IMWPU * txtELPSQ
'            End If
'        Else
'            txtELPSW = 0
'        End If
'        txtELPSW.SetFocus
'    End If
'End Sub

'Private Sub txtELPSQ_LostFocus()
'
'        Dim RecIIM As Recordset
'        Set RecIIM = DBconn.Execute("Select IMWPU from IIM where IMITN='" & txtELITN & "'")
'        If Not RecIIM.EOF Then
'            If IsNull(RecIIM!IMWPU) Then
'                txtELPSW = ""
'                txtELPSW.SetFocus
'            Else
'                txtELPSW = RecIIM!IMWPU * txtELPSQ
'            End If
'
'        Else
'            txtELPSW = 0
'        End If
'End Sub





'Private Sub txtELPSW_KeyPress(KeyAscii As Integer)
'    If KeyAscii = 13 Then
'        txtELPDC.SetFocus
'    End If
'End Sub

Private Sub txtELQTY_KeyPress(KeyAscii As Integer)
On Error GoTo Err_action
    If KeyAscii = 13 Then
        
        Dim RecIIM As Recordset
        Set RecIIM = DBconn.Execute("Select IMWPU from IIM where IMITN='" & txtELITN & "'")
        If Not RecIIM.EOF Then
            If IsNull(RecIIM!IMWPU) Then
                txtELWGT = ""
                txtELWGT.SetFocus
            Else
                txtELWGT = RecIIM!IMWPU * txtELQTY
                txtELPDC.SetFocus
            End If
        Else
           txtELWGT.SetFocus
        End If
        Call RefeshLineAmount
    End If
    
Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action
End Sub

Private Sub txtELQTY_LostFocus()
On Error GoTo Err_action
      'txtELWGT.SetFocus
        Dim RecIIM As Recordset
        Set RecIIM = DBconn.Execute("Select IMWPU from IIM where IMITN='" & txtELITN & "'")
        If Not RecIIM.EOF Then
            If IsNull(RecIIM!IMWPU) Then
                MsgBox "Nhap vao khoi luong tuong ung"
                txtELWGT = 0
                'txtELWGT.SetFocus
            Else
                txtELWGT = RecIIM!IMWPU * txtELQTY
                 Call RefeshLineAmount
                'txtELPDC.SetFocus
            End If
        Else
            MsgBox "Nhap vao khoi luong tuong ung"
            'txtELWGT.SetFocus
        End If

Next_Action:
    Exit Sub
Err_action:
    MsgBox Err.Description
    Resume Next_Action

End Sub

Private Sub txtELVAM_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then cmdSave.SetFocus
End Sub


Private Sub txtELWGT_KeyPress(KeyAscii As Integer)
    On Error Resume Next
    
    If KeyAscii = 13 Then
        If Val(txtELWGT) <= 0 Then
            MsgBox "Gia tri khong hop le"
            txtELWGT.SetFocus
        Else
            Call RefeshLineAmount
            txtELPDC.SetFocus
            Call RefeshLineAmount
        End If
    End If

End Sub
Private Sub txtELWGT_LostFocus()
    On Error Resume Next
        If Val(txtELWGT) <= 0 Then
            MsgBox "Gia tri khong hop le"
            'txtELWGT.SetFocus
        Else
            Call RefeshLineAmount
        End If
    
End Sub
Function ValidInput()
On Error GoTo ValidInput_err
Dim Result
Dim StrErr As String, Havelot As Byte
Havelot = False
If Not IsDate(txtEHDTE) Then StrErr = StrErr & Chr(13) & "* Wrong Invoice Date!"
If Not IsDate(txtEHDUE) Then StrErr = StrErr & Chr(13) & "* Wrong Due Date!"
If Find("RCM", "CMCNO", "WHERE CMCNO='" & txtEHCNO & "'") = "" Then StrErr = StrErr & Chr(13) & "* Not have Customer"

If Find("CCM", "CMCCD", "WHERE CMCCD='" & cboEHCCD.BoundText & "'") = "" Then StrErr = StrErr & Chr(13) & "* Not have Currency code"


If txtELQTY = 0 Then StrErr = StrErr & Chr(13) & "* Quantity must be >0"
If txtELWGT = 0 Then StrErr = StrErr & Chr(13) & "* Weight must be >0"
If StrErr <> "" Then
    MsgBox "Please check again!" & StrErr
    ValidInput = False
Else
    ValidInput = True
End If
ValidInput_next:
    Exit Function
ValidInput_err:
    MsgBox "ValidInput Error : " & Err.Description
    Resume ValidInput_next:
End Function




